/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.protocol.passive;

import info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.BCD;
import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.BIT;

/**
 * <b>(DianlanChargingMachineSuspend)</b>
 * <p>
 * 充电阶段充电机中止，GBT-27930 充电桩与 BMS 充电阶段充电机中止报文
 * 帧类型码 0x21(33)
 * 序列号域 0018
 * 数据长度 32
 * 帧校验域 8445
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/8/19
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class DianlanChargingMachineSuspend {
    /** 交易流水号 */
    @DianlanProtocol(length = 16, start = 0, end = 16, dataType = BCD)
    String transNo;
    /** 桩编码 */
    @DianlanProtocol(length = 7, start = 16, end = 23, dataType = BCD)
    String stubNo;
    /** 充电枪号 */
    @DianlanProtocol(length = 1, start = 23, end = 24, dataType = BCD)
    String chargingPortNo;
    /**
     * 充电机 中止充电原因
     * <p>
     * 1-2 位——达到充电机设定的条件中止
     * 3-4 位——人工中止
     * 5-6 位——异常中止
     * 7-8 位——BMS 主动中止
     */
    @DianlanProtocol(length = 1, start = 24, end = 25, dataType = BIT, dataTypeClass = "DianlanMachineSuspendReasonBits")
    String machineSuspendReason;
    /**
     * 充电机 中止充电故障原因
     * <p>
     * 1-2 位——充电机过温故障
     * 3-4 位——充电连接器故障
     * 5-6 位——充电机内部过温故障
     * 7-8 位——所需电量不能传送
     * 9-10 位——充电机急停故障
     * 11-12 位——其他故障
     * 13-16 位——预留位
     */
    @DianlanProtocol(length = 2, start = 25, end = 27, dataType = BIT, dataTypeClass = "DianlanMachineSuspendMalfunctionReasonBits")
    String machineSuspendMalfunctionReason;
    /**
     * 充电机 中止充电错误原因
     * <p>
     * 1-2 位——电流不匹配
     * 3-4 位——电压异常
     * 5-8 位——预留位
     */
    @DianlanProtocol(length = 1, start = 27, end = 28, dataType = BIT, dataTypeClass = "DianlanMachineSuspendFailureReasonBits")
    String machineSuspendFailureReason;
}